package com.jinzecloud.fiction.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.jinzecloud.fiction.bean.TbCarte;
import com.jinzecloud.fiction.service.TbCarteService;
import com.jinzecloud.fiction.utils.PageUtils;
import com.jinzecloud.fiction.utils.R;


/**
 * 分类表
 *
 * @author ??
 * @email 1971240051@qq.com
 * @date 2023-10-19 19:38:04
 */
@RestController
@RequestMapping("fiction/tbcarte")
public class TbCarteController {
    @Autowired
    private TbCarteService tbCarteService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("fiction:tbcarte:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = tbCarteService.queryPage(params);

        return R.ok().put("page", page);
    }

    @RequestMapping("/getList")
    //@RequiresPermissions("fiction:tbcarte:list")
    public R getList(@RequestParam Map<String, Object> params){
        List list = tbCarteService.getList(params);

//        return R.ok().put("page", page);
        return R.ok().put("data",list);
    }

    @RequestMapping("/getCarteNameAndId")
    //@RequiresPermissions("fiction:tbcarte:list")
    public R getCarteNameAndId(){
        List list = tbCarteService.getCarteNameAndId();

//        return R.ok().put("page", page);
        return R.ok().put("data",list);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{caId}")
    //@RequiresPermissions("fiction:tbcarte:info")
    public R info(@PathVariable("caId") Integer caId){
		TbCarte tbCarte = tbCarteService.getById(caId);
        return R.ok().put("tbCarte", tbCarte);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("fiction:tbcarte:save")
    public R save(@RequestBody TbCarte tbCarte){
		tbCarteService.saveCarte(tbCarte);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("fiction:tbcarte:update")
    public R update(@RequestBody TbCarte tbCarte){
		tbCarteService.updateById(tbCarte);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("fiction:tbcarte:delete")
    public R delete(@RequestBody Integer[] caIds){
		tbCarteService.removeByIds(Arrays.asList(caIds));

        return R.ok();
    }

}
